﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="frmProductoAlta.aspx.cs" Inherits="frmProductoAlta" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <style type="text/css">
        .style1
        {
        }
        .style2
        {
            width: 142px;
        }
        .style3
        {
            height: 0px;
        }
        .style5
        {
            width: 227px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
       <h1>Registrar Nuevo Producto
           <asp:Label ID="Label2" runat="server"></asp:Label>
       </h1>
 RNPA
       <p>
           <asp:TextBox ID="TextBox1" runat="server" Height="26px" Width="184px" 
           ></asp:TextBox>
          <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
               ControlToValidate="TextBox1" ErrorMessage="Ingrese RNPA" Enabled="False" 
               Font-Bold="True" ForeColor="Red"></asp:RequiredFieldValidator>      
           &nbsp;      
           <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" 
               oncheckedchanged="CheckBox1_CheckedChanged" 
               Text=" En proceso de obtención" />

       <p>Denominacion</p>

           <asp:TextBox ID="TextBox4" runat="server" Height="26px" Width="184px"></asp:TextBox>
      <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
               ControlToValidate="TextBox4" ErrorMessage="Ingrese denominacion" 
           Font-Bold="True" ForeColor="Red"></asp:RequiredFieldValidator>

       <p>Marca</p>
           <asp:TextBox ID="TextBox2" runat="server" Width="184px" Height="26px"></asp:TextBox>
       <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
               ControlToValidate="TextBox2" ErrorMessage="Ingrese marca" 
           Font-Bold="True" ForeColor="Red"></asp:RequiredFieldValidator>

       <p>Nombre de Fantasia</p>
           <asp:TextBox ID="TextBox3" runat="server" Width="184px" Height="26px"></asp:TextBox>
           <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
               ControlToValidate="TextBox3" ErrorMessage="Ingrese nombre de fantasia" 
           Font-Bold="True" ForeColor="#FF3300"></asp:RequiredFieldValidator>

       <p>Seleccione Envase </p>
           <asp:DropDownList ID="DropDownList1" runat="server" Height="28px" Width="184px" 
               DataSourceID="SqlDataSource1" DataTextField="tipoEnvase" 
               DataValueField="idEnvase">
           </asp:DropDownList>
           <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
               ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
               SelectCommand="SELECT * FROM [T_Envase] where [habilitado] &gt; 0"></asp:SqlDataSource>
           <asp:SqlDataSource ID="SqlDataSource4" runat="server" 
               ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
               DeleteCommand="DELETE FROM [T_Empresa] WHERE [cuit] = @cuit" 
               InsertCommand="INSERT INTO [T_Empresa] ([cuit], [razonSocial], [nombreComercial], [dirCorreo], [dirWeb], [numTelefono], [idTipoTelefono], [idCondIva], [calle], [numeroCalle], [piso], [departamento], [codPostal], [idBarrio], [idLocalidad], [idProvincia], [idPais]) VALUES (@cuit, @razonSocial, @nombreComercial, @dirCorreo, @dirWeb, @numTelefono, @idTipoTelefono, @idCondIva, @calle, @numeroCalle, @piso, @departamento, @codPostal, @idBarrio, @idLocalidad, @idProvincia, @idPais)" 
               SelectCommand="SELECT [cuit], [razonSocial], [nombreComercial], [dirCorreo], [dirWeb], [numTelefono], [idTipoTelefono], [idCondIva], [calle], [numeroCalle], [piso], [departamento], [codPostal], [idBarrio], [idLocalidad], [idProvincia], [idPais] FROM [T_Empresa] where cuit = @cuit_empresa" 
               
           UpdateCommand="UPDATE [T_Empresa] SET [razonSocial] = @razonSocial, [nombreComercial] = @nombreComercial, [dirCorreo] = @dirCorreo, [dirWeb] = @dirWeb, [numTelefono] = @numTelefono, [idTipoTelefono] = @idTipoTelefono, [idCondIva] = @idCondIva, [calle] = @calle, [numeroCalle] = @numeroCalle, [piso] = @piso, [departamento] = @departamento, [codPostal] = @codPostal, [idBarrio] = @idBarrio, [idLocalidad] = @idLocalidad, [idProvincia] = @idProvincia, [idPais] = @idPais WHERE [cuit] = @cuit">
               <DeleteParameters>
                   <asp:Parameter Name="cuit" Type="String" />
               </DeleteParameters>
               <InsertParameters>
                   <asp:Parameter Name="cuit" Type="String" />
                   <asp:Parameter Name="razonSocial" Type="String" />
                   <asp:Parameter Name="nombreComercial" Type="String" />
                   <asp:Parameter Name="dirCorreo" Type="String" />
                   <asp:Parameter Name="dirWeb" Type="String" />
                   <asp:Parameter Name="numTelefono" Type="String" />
                   <asp:Parameter Name="idTipoTelefono" Type="Int32" />
                   <asp:Parameter Name="idCondIva" Type="Int32" />
                   <asp:Parameter Name="calle" Type="String" />
                   <asp:Parameter Name="numeroCalle" Type="String" />
                   <asp:Parameter Name="piso" Type="String" />
                   <asp:Parameter Name="departamento" Type="String" />
                   <asp:Parameter Name="codPostal" Type="String" />
                   <asp:Parameter Name="idBarrio" Type="Int32" />
                   <asp:Parameter Name="idLocalidad" Type="Int32" />
                   <asp:Parameter Name="idProvincia" Type="Int32" />
                   <asp:Parameter Name="idPais" Type="Int32" />
               </InsertParameters>
               <SelectParameters>
                   <asp:SessionParameter DefaultValue="0" Name="cuit_empresa" 
                       SessionField="codEmpresa" />
               </SelectParameters>
               <UpdateParameters>
                   <asp:Parameter Name="razonSocial" Type="String" />
                   <asp:Parameter Name="nombreComercial" Type="String" />
                   <asp:Parameter Name="dirCorreo" Type="String" />
                   <asp:Parameter Name="dirWeb" Type="String" />
                   <asp:Parameter Name="numTelefono" Type="String" />
                   <asp:Parameter Name="idTipoTelefono" Type="Int32" />
                   <asp:Parameter Name="idCondIva" Type="Int32" />
                   <asp:Parameter Name="calle" Type="String" />
                   <asp:Parameter Name="numeroCalle" Type="String" />
                   <asp:Parameter Name="piso" Type="String" />
                   <asp:Parameter Name="departamento" Type="String" />
                   <asp:Parameter Name="codPostal" Type="String" />
                   <asp:Parameter Name="idBarrio" Type="Int32" />
                   <asp:Parameter Name="idLocalidad" Type="Int32" />
                   <asp:Parameter Name="idProvincia" Type="Int32" />
                   <asp:Parameter Name="idPais" Type="Int32" />
                   <asp:Parameter Name="cuit" Type="String" />
               </UpdateParameters>
           </asp:SqlDataSource>
       </p>
       <p>
           <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
               ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
               DeleteCommand="DELETE FROM [T_DetalleComposicion] WHERE [idRNPA] = @idRNPA" 
               InsertCommand="INSERT INTO [T_DetalleComposicion] ([idRNPA], [idComponente], [cantidad], [unidad]) VALUES (@idRNPA, @idComponente, @cantidad, @unidad)" 
               SelectCommand="SELECT [idRNPA], [idComponente], [cantidad], [unidad], [idDetalle] FROM [T_DetalleComposicion]" 
               
               UpdateCommand="UPDATE [T_DetalleComposicion] SET [idRNPA] = @idRNPA, [idComponente] = @idComponente, [cantidad] = @cantidad, [unidad] = @unidad WHERE [idDetalle] = @idDetalle">
               <DeleteParameters>
                   <asp:Parameter Name="idRNPA" />
               </DeleteParameters>
               <InsertParameters>
                   <asp:Parameter Name="idRNPA" Type="Int32" />
                   <asp:Parameter Name="idComponente" Type="Int32" />
                   <asp:Parameter Name="cantidad" Type="String" />
                   <asp:Parameter Name="unidad" Type="Int32" />
               </InsertParameters>
               <UpdateParameters>
                   <asp:Parameter Name="idRNPA" Type="Int32" />
                   <asp:Parameter Name="idComponente" Type="Int32" />
                   <asp:Parameter Name="cantidad" Type="String" />
                   <asp:Parameter Name="unidad" Type="Int32" />
                   <asp:Parameter Name="idDetalle" Type="Int32" />
               </UpdateParameters>
           </asp:SqlDataSource>
       </p>
       <p>
           <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
               ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
               DeleteCommand="DELETE FROM [T_Producto] WHERE [idProducto] = @idProducto" 
               InsertCommand="INSERT INTO [T_Producto] ([nroRNPA], [nroRNE], [denominacion], [marca], [fantasia], [codEnvase], [infoCompl], [marcoLegal], [tecnicaElab], [deterioro], [ensayo], [conserv], [aptitud], [modo], [habilitado]) VALUES (@nroRNPA, @nroRNE, @denominacion, @marca, @fantasia, @codEnvase, @infoCompl, @marcoLegal, @tecnicaElab, @deterioro, @ensayo, @conserv, @aptitud, @modo, @habilitado)" 
               SelectCommand="SELECT [nroRNPA], [nroRNE], [denominacion], [marca], [fantasia], [codEnvase], [idProducto], [infoCompl], [marcoLegal], [tecnicaElab], [deterioro], [ensayo], [conserv], [aptitud], [modo], [habilitado] FROM [T_Producto]" 
               
               UpdateCommand="UPDATE [T_Producto] SET [nroRNPA] = @nroRNPA, [nroRNE] = @nroRNE, [denominacion] = @denominacion, [marca] = @marca, [fantasia] = @fantasia, [codEnvase] = @codEnvase, [infoCompl] = @infoCompl, [marcoLegal] = @marcoLegal, [tecnicaElab] = @tecnicaElab, [deterioro] = @deterioro, [ensayo] = @ensayo, [conserv] = @conserv, [aptitud] = @aptitud, [modo] = @modo, [habilitado] = @habilitado WHERE [idProducto] = @idProducto">
               <DeleteParameters>
                   <asp:Parameter Name="idProducto" Type="Int32" />
               </DeleteParameters>
               <InsertParameters>
                   <asp:Parameter Name="nroRNPA" Type="String" />
                   <asp:Parameter Name="nroRNE" Type="Int32" />
                   <asp:Parameter Name="denominacion" Type="String" />
                   <asp:Parameter Name="marca" Type="String" />
                   <asp:Parameter Name="fantasia" Type="String" />
                   <asp:Parameter Name="codEnvase" Type="Int32" />
                   <asp:Parameter Name="infoCompl" Type="String" />
                   <asp:Parameter Name="marcoLegal" Type="String" />
                   <asp:Parameter Name="tecnicaElab" Type="String" />
                   <asp:Parameter Name="deterioro" Type="String" />
                   <asp:Parameter Name="ensayo" Type="String" />
                   <asp:Parameter Name="conserv" Type="String" />
                   <asp:Parameter Name="aptitud" Type="String" />
                   <asp:Parameter Name="modo" Type="String" />
                   <asp:Parameter Name="habilitado" Type="String" />
               </InsertParameters>
               <UpdateParameters>
                   <asp:Parameter Name="nroRNPA" Type="String" />
                   <asp:Parameter Name="nroRNE" Type="Int32" />
                   <asp:Parameter Name="denominacion" Type="String" />
                   <asp:Parameter Name="marca" Type="String" />
                   <asp:Parameter Name="fantasia" Type="String" />
                   <asp:Parameter Name="codEnvase" Type="Int32" />
                   <asp:Parameter Name="infoCompl" Type="String" />
                   <asp:Parameter Name="marcoLegal" Type="String" />
                   <asp:Parameter Name="tecnicaElab" Type="String" />
                   <asp:Parameter Name="deterioro" Type="String" />
                   <asp:Parameter Name="ensayo" Type="String" />
                   <asp:Parameter Name="conserv" Type="String" />
                   <asp:Parameter Name="aptitud" Type="String" />
                   <asp:Parameter Name="modo" Type="String" />
                   <asp:Parameter Name="habilitado" Type="String" />
                   <asp:Parameter Name="idProducto" Type="Int32" />
               </UpdateParameters>
           </asp:SqlDataSource>
       
           <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
               DataKeyNames="idEnvase" DataSourceID="SqlDataSource5" 
               EmptyDataText="No hay registros de datos para mostrar." Visible="False" 
               Height="16px" Width="368px">
               <Columns>
                   <asp:BoundField DataField="idEnvase" HeaderText="idEnvase" ReadOnly="True" 
                       SortExpression="idEnvase" />
                   <asp:BoundField DataField="tipoEnvase" HeaderText="tipoEnvase" 
                       SortExpression="tipoEnvase" />
                   <asp:BoundField DataField="capacidadEnvase" HeaderText="capacidadEnvase" 
                       SortExpression="capacidadEnvase" />
                   <asp:BoundField DataField="presentacionEnvase" HeaderText="presentacionEnvase" 
                       SortExpression="presentacionEnvase" />
               </Columns>
           </asp:GridView>
           <asp:SqlDataSource ID="SqlDataSource5" runat="server" 
               ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
               DeleteCommand="DELETE FROM [T_Envase] WHERE [idEnvase] = @idEnvase" 
               InsertCommand="INSERT INTO [T_Envase] ([tipoEnvase], [capacidadEnvase], [presentacionEnvase]) VALUES (@tipoEnvase, @capacidadEnvase, @presentacionEnvase)" 
               SelectCommand="SELECT [idEnvase], [tipoEnvase], [capacidadEnvase], [presentacionEnvase] FROM [T_Envase] where idEnvase = @envase" 
               
               UpdateCommand="UPDATE [T_Envase] SET [tipoEnvase] = @tipoEnvase, [capacidadEnvase] = @capacidadEnvase, [presentacionEnvase] = @presentacionEnvase WHERE [idEnvase] = @idEnvase">
               <DeleteParameters>
                   <asp:Parameter Name="idEnvase" Type="Int32" />
               </DeleteParameters>
               <InsertParameters>
                   <asp:Parameter Name="tipoEnvase" Type="String" />
                   <asp:Parameter Name="capacidadEnvase" Type="String" />
                   <asp:Parameter Name="presentacionEnvase" Type="String" />
               </InsertParameters>
               <SelectParameters>
                   <asp:SessionParameter Name="envase" SessionField="cod_envase" />
               </SelectParameters>
               <UpdateParameters>
                   <asp:Parameter Name="tipoEnvase" Type="String" />
                   <asp:Parameter Name="capacidadEnvase" Type="String" />
                   <asp:Parameter Name="presentacionEnvase" Type="String" />
                   <asp:Parameter Name="idEnvase" Type="Int32" />
               </UpdateParameters>
           </asp:SqlDataSource>

       <p>
           &nbsp;<p>
           <asp:Button ID="Button1" runat="server" Height="35px" onclick="Button1_Click" 
               Text="Cargar Composicion" Width="156px" />
           &nbsp;&nbsp;&nbsp;&nbsp;
           <asp:Button ID="Button3" runat="server" Height="35px" Text="Cargar Monografía" 
               Width="154px" CausesValidation="False" onclick="Button3_Click" />
       </p>
       <p>
           &nbsp;</p>
       <p>
           <asp:Button ID="Button5" runat="server" Height="48px" Text="Registrar Producto" 
               Width="155px" onclick="Button5_Click" Enabled="False" />

           &nbsp;&nbsp;&nbsp;&nbsp;

           <asp:Button ID="Button4" runat="server" Height="48px" Text="Cancelar Registro" 
               Width="156px" CausesValidation="False" onclick="Button4_Click" />

       </p>


           <asp:Label ID="Label1" runat="server" Font-Bold="True" ForeColor="#0033CC"></asp:Label>

                       <br />
           <table style="width:100%;">
               <tr>
               
                   <td colspan="2" height="60">
           <asp:Button ID="Button6" runat="server" CausesValidation="False" Height="33px" 
               onclick="Button6_Click" Text="Administrar Productos" 
               Width="335px" />
                       </td>
               </tr>
               <tr>
                   <td class="style5">
                   
                       Opciones de documentacion</td>
                   <td class="style1">
                   
                       </td>
               </tr>

               <tr>
                   <td class="style5" height="50">
                       <asp:Button ID="Button7" runat="server" CausesValidation="False" Height="26px" 
                           onclick="Button7_Click" Text="Generar Monografia" Width="140px" 
                           Enabled="False" />
                       <br />
                   </td>
                   <td class="style2">
                       </td>
               </tr>

               <tr>
                   <td class="style5" height="50">
                      <asp:Button ID="Button8" runat="server" CausesValidation="False" 
                           Height="26px" onclick="Button8_Click1" Text="Generar Rotulo" 
                           Width="140px" />
                   </td>
                   <td class="style2">
                       &nbsp;</td>
               </tr>
               <tr>
                   <td class="style5">
                       <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                           datasourceid="SqlDataSource6" 
                           EmptyDataText="No hay registros de datos para mostrar." Visible="False" 
                           Height="1px" Width="138px" AllowPaging="True" HorizontalAlign="Right" 
                           PageSize="2">
                           <Columns>
                               <asp:BoundField DataField="cantidad" HeaderText="cantidad" 
                                   SortExpression="cantidad" />
                               <asp:BoundField DataField="Unidad" HeaderText="Unidad" 
                                   SortExpression="Unidad" />
                               <asp:BoundField DataField="Componente" HeaderText="Componente" 
                                   SortExpression="Componente" />
                               <asp:BoundField DataField="nroIns" HeaderText="nroIns" 
                                   SortExpression="nroIns" />
                           </Columns>
                       </asp:GridView>
                       <br />
                       <asp:SqlDataSource ID="SqlDataSource6" runat="server" 
                           ConnectionString="<%$ ConnectionStrings:BD_SAFA_FINALConnectionString %>" 
                           DeleteCommand="DELETE FROM [T_DetalleComposicion] WHERE [idDetalle] = @idDetalle" 
                           InsertCommand="INSERT INTO [T_DetalleComposicion] ([idRNPA], [idComponente], [cantidad], [unidad]) VALUES (@idRNPA, @idComponente, @cantidad, @unidad)" 
                           SelectCommand="SELECT T_DetalleComposicion.cantidad, T_Unidades.descripcion AS Unidad, T_TipoIngrediente.descripcion AS Componente, T_TipoIngrediente.nroIns FROM T_DetalleComposicion INNER JOIN T_TipoIngrediente ON T_DetalleComposicion.idComponente = T_TipoIngrediente.idComponente INNER JOIN T_Unidades ON T_DetalleComposicion.unidad = T_Unidades.idUnidad WHERE (T_DetalleComposicion.idRNPA = @rnpa)" 
                           UpdateCommand="UPDATE [T_DetalleComposicion] SET [idRNPA] = @idRNPA, [idComponente] = @idComponente, [cantidad] = @cantidad, [unidad] = @unidad WHERE [idDetalle] = @idDetalle">
                           <DeleteParameters>
                               <asp:Parameter Name="idDetalle" Type="Int32" />
                           </DeleteParameters>
                           <InsertParameters>
                               <asp:Parameter Name="idRNPA" Type="Int32" />
                               <asp:Parameter Name="idComponente" Type="Int32" />
                               <asp:Parameter Name="cantidad" Type="String" />
                               <asp:Parameter Name="unidad" Type="Int32" />
                           </InsertParameters>
                           <SelectParameters>
                               <asp:SessionParameter Name="rnpa" SessionField="RNPA" />
                           </SelectParameters>
                           <UpdateParameters>
                               <asp:Parameter Name="idRNPA" Type="Int32" />
                               <asp:Parameter Name="idComponente" Type="Int32" />
                               <asp:Parameter Name="cantidad" Type="String" />
                               <asp:Parameter Name="unidad" Type="Int32" />
                               <asp:Parameter Name="idDetalle" Type="Int32" />
                           </UpdateParameters>
                       </asp:SqlDataSource>
                      </td>
               </tr>
           </table>
       </p>
</asp:Content>

